home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / ATL / src / Atl.cpp next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  3.5 KB  |  125 lines

  1. // atl.cpp : Implementation of DLL Exports.
  2.  
  3. // You will need the NT SUR Beta 2 SDK or VC 4.2 or higher in order to build
  4. // this project.  This is because you will need MIDL 3.00.15 or higher and new
  5. // headers and libs.  If you have VC 4.2 installed, then everything should
  6. // already be configured correctly.
  7.  
  8. // Note: Proxy/Stub Information
  9. //      To build a separate proxy/stub DLL,
  10. //      run nmake -f atlps.mak in the project directory.
  11.  
  12. #include "stdafx.h"
  13. #include "resource.h"
  14. #include "RegObj.h"
  15.  
  16. #define _ATLBASE_IMPL
  17. #include <atlbase.h>
  18. #define _ATLCOM_IMPL
  19. #include <atlcom.h>
  20. #define _ATLWIN_IMPL
  21. #include <atlwin.h>
  22. #define _ATLCTL_IMPL
  23. #include <atlctl.h>
  24. #define _ATLCONV_IMPL
  25. #include <atlconv.h>
  26. #define _ATLHOST_IMPL
  27. #include <atlhost.h>
  28.  
  29. CComModule _Module;
  30.  
  31. BEGIN_OBJECT_MAP(ObjectMap)
  32.     OBJECT_ENTRY(CLSID_Registrar, CDLLRegObject)
  33.     OBJECT_ENTRY_NON_CREATEABLE(CAxHostWindow)
  34. END_OBJECT_MAP()
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // DLL Entry Point
  38.  
  39. extern "C"
  40. BOOL WINAPI DllMain(WCE_IF(HANDLE, HINSTANCE) hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  41. {
  42.     if (dwReason == DLL_PROCESS_ATTACH)
  43.     {
  44. #if !defined(_WIN32_WCE)
  45.         OSVERSIONINFOA info;
  46.         info.dwOSVersionInfoSize = sizeof(info);
  47.         if (GetVersionExA(&info))
  48.         {
  49. #ifdef _UNICODE
  50.             if (info.dwPlatformId != VER_PLATFORM_WIN32_NT)
  51.             {
  52.                 MessageBoxA(NULL, "Can not run Unicode version of ATL.DLL on Windows 95.\nPlease install the correct version.", "ATL", MB_ICONSTOP|MB_OK);
  53.                 return FALSE;
  54.             }
  55. #else
  56.             if (info.dwPlatformId == VER_PLATFORM_WIN32_NT)
  57.             {
  58.                 OutputDebugString(_T("Running Ansi version of ATL.DLL on Windows NT : Slight Performace loss.\nPlease install the UNICODE version on NT.\n"));
  59.             }
  60. #endif
  61.         }
  62. #ifdef _DEBUG
  63.         _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF);
  64.         int n = 0;
  65.         _CrtSetBreakAlloc(n);
  66. #endif
  67. #endif // _WIN32_WCE
  68.         _Module.Init(ObjectMap, WCE_IF((HINSTANCE),())hInstance, &LIBID_ATLLib);
  69. #ifdef _ATL_DEBUG_INTERFACES
  70.         int ni = 0;
  71.         _Module.m_nIndexBreakAt = ni;
  72. #endif // _ATL_DEBUG_INTERFACES
  73.         WCE_DEL DisableThreadLibraryCalls(hInstance);
  74.     }
  75.     else if (dwReason == DLL_PROCESS_DETACH)
  76.     {
  77. #ifdef _DEBUG
  78.         ::OutputDebugString(_T("ATL.DLL exiting.\n"));
  79. #endif
  80.         _Module.Term();
  81.         AtlAxWinTerm();
  82. #if !defined(_WIN32_WCE)
  83. #ifdef _DEBUG
  84.         if (_CrtDumpMemoryLeaks())
  85.             ::MessageBeep(MB_ICONEXCLAMATION);
  86. #endif
  87. #endif // _WIN32_WCE
  88.     }
  89.     return TRUE;    // ok
  90. }
  91.  
  92. /////////////////////////////////////////////////////////////////////////////
  93. // Used to determine whether the DLL can be unloaded by OLE
  94.  
  95. STDAPI DllCanUnloadNow(void)
  96. {
  97.     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  98. }
  99.  
  100. /////////////////////////////////////////////////////////////////////////////
  101. // Returns a class factory to create an object of the requested type
  102.  
  103. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  104. {
  105.     return _Module.GetClassObject(rclsid, riid, ppv);
  106. }
  107.  
  108. /////////////////////////////////////////////////////////////////////////////
  109. // DllRegisterServer - Adds entries to the system registry
  110.  
  111. STDAPI DllRegisterServer(void)
  112. {
  113.     // registers object, typelib and all interfaces in typelib
  114.     return _Module.RegisterServer(TRUE);
  115. }
  116.  
  117. /////////////////////////////////////////////////////////////////////////////
  118. // DllUnregisterServer - Removes entries from the system registry
  119.  
  120. STDAPI DllUnregisterServer(void)
  121. {
  122.     //No need to unregister typelib since ATL is a system component.
  123.     return S_OK;
  124. }
  125.